package com.example.personnel_oa.controller;
//Controler负责请求转发，接受页面过来的参数，传给Service处理，接到返回值，再传给页面。
import com.example.comment_oa.pojos.Contract;
import com.example.comment_oa.pojos.Dimission;
import com.example.comment_oa.response.AjaxResponse;
import com.example.personnel_oa.service.DimissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
//控制器类
@CrossOrigin
//禁止Ajax访问当前站点外的资源
@Controller
//控制器
@RequestMapping("/personnelOa")
//跨域处理请求
public class DimissionController {
    @Autowired
    //注入
    DimissionService dimissionService;
    @GetMapping("/Dimission/alldim")
    //用于处理请求方法的GET类型
    public AjaxResponse Methods_dim(){
        return AjaxResponse.success(dimissionService.Methods_dim());
    }
    @GetMapping("/Dimission/allDimission")
    //用于处理请求方法的GET类型
    public AjaxResponse allDimission(){ return AjaxResponse.success(dimissionService.allDimission());}

    @PostMapping("/Dimission/allrelieve/{dimid}")
    //用于处理请求方法的POST*类型
    public AjaxResponse allrelieve(@PathVariable("dimid") int dimId){
        return AjaxResponse.success(dimissionService.allrelieve(dimId));
    }
    // 申请离职新增一条数据
    @PostMapping("Dimission/shenqinglizhi")
    //用于处理请求方法的POST*类型
    public AjaxResponse shenqinglizhi(@RequestBody Dimission dimission){
        System.err.println(dimission.getEmpId());
        int i = dimissionService.shenqinglizhi(dimission);
        return AjaxResponse.success(i);
    }
    //根据工号查询离职审批数据详情
    @GetMapping("Dimission/dimBianhao/{dimBianhao}")
    //用于处理请求方法的GET类型
    public AjaxResponse dimBianhao(@PathVariable("dimBianhao") String dimBianhao){
        return AjaxResponse.success(dimissionService.dimBiaanhao(dimBianhao));
    }
}
